package cn.tedu.submarine2;

import cn.tedu.submarine2.Bomb;
import cn.tedu.submarine2.Images;
import cn.tedu.submarine2.SeaObject;

import javax.swing.*;

/**
 * 战舰类
 */
public class Battleship extends SeaObject {

    private int life;

    public Battleship() {
        super(66,26,270,124,20);
        life = 5;
    }


    public void move() {
    }

    /**
     * 返回战舰图片
     */
    public ImageIcon getImage() {
        return Images.battleship;
    }

    /**
     * 战舰向左移动
     */
    public void moveLeft(){
       x -= speed;
    }

    /**
     * 战舰向右移动
     */
    public void moveRight(){
        x += speed;
    }

    /**
     * 战舰发射子弹
     */
    public Bomb shootBomb(){
        return new Bomb(this.x,this.y);
    }

    /**
     * 战舰增加命数
     */
    public void addLife(int num){
        life += num;
    }

    /**
     * 战舰获取命数
     */
    public int getLife(){
        return life;
    }

    /**
     * 战舰丢失命数
     */
    public void subtractLife(){
        life--;
    }

}
